package org.notes;

import lombok.SneakyThrows;

import java.nio.file.*;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    @SneakyThrows
    public static void main(String[] args) {
        //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
        // to see how IntelliJ IDEA suggests fixing it.
        WatchService watchService = FileSystems.getDefault().newWatchService();
        Paths.get("d://").register(
                watchService,
                StandardWatchEventKinds.ENTRY_CREATE,
                StandardWatchEventKinds.ENTRY_DELETE,
                StandardWatchEventKinds.ENTRY_MODIFY);
        WatchKey take = watchService.take();
        while (take.isValid()) {
            for (WatchEvent<?> event : take.pollEvents()) {
                System.out.println(event.context() + "\t" + event.kind() +"\t" + event.count());
            }
            take.reset();
        }
    }
}